import axios from "axios";
import { Message } from "element-ui";
import router from "../router";
 
//请求拦截器
axios.interceptors.request.use(
  (config) => {
   
    return config;
  },
  (error) => {
    console.log(error);
  }
);

//响应拦截器
axios.interceptors.response.use(
  (success)=>{
  
    return success.data;

    //test 
  },
  (error)=>{
    
     console.log("error");
     console.log(error);
  }
);

let base = "";
export const postRequest = (url, params) => {
  return axios({
    method: "post",
    url: `${base}${url}`,
    data: params,
  });
};

// put 请求
export const putRequest = (url, params) => {
  return axios({
    method: "put",
    url: `${base}${url}`,
    data: params,
  });
};


//参数改成params 
export const getRequest = (url, params) => {
  return axios({
    method: "get",
    url: `${base}${url}`,
    params: params,
  });
};

// 传送token 的delete 请求
export const deleteRequest = (url,data) => {
  return axios({
    method: "delete",
    url: `${base}${url}`,
    data : data
  });
};
 

 export const getMenuItem = (url,params) => { 
  return axios({
    method: "get",
    url: `${base}${url}`,
    data: params,
  })

};


export const uploadRequest = (url, params , headers) => {
  return axios({
    method: "post",
    url: `${base}${url}`,
    data: params,
    headers  : headers
  });
};


 
  
